home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / gui / gui4cli.lha / Gui4Cli / Ext / GCSound / GCSound.gc < prev    next >
Text File  |  1998-10-22  |  14KB  |  560 lines

  1. G4C
  2.  
  3. WINBIG 275 29 250 136 'GCSound 8SVX Player'
  4. WinType 11110001
  5.  
  6. ; ===============================================================
  7. ;       general events
  8. ; ===============================================================
  9.  
  10. xOnLoad
  11. mode = DIR                              ; can be SAMPLE or DIR
  12. selswitch = 0                           ; delect/deselect dir lv switch
  13. setgad #this 10 hide                    ; hide the samples lv
  14. setgad gcsound.gc 2 HIDE                ; and it's text box
  15. GuiOpen #this
  16. name = ''                               ; set these for safety
  17. volume = 64
  18. speed = -1
  19. times = 0
  20. status = IDLE
  21. setwin = CLOSED
  22. gcsound.set/oldspeed = -1
  23. lvuse gcsound.gc 1
  24. setwintitle #this '$$lv.dir                         '
  25. run 'guis:ext/gcsound/gcsound'          ; load extension
  26.  
  27. xOnClose
  28. guiclose #this
  29. setgad #this 5 on                       ; appicon on
  30.  
  31. xOnQuit
  32. guiquit gcsound.pop
  33. guiquit gcsound.set
  34. call gcsound quit
  35.  
  36. xOnRMB
  37. if $mode = SAMPLE
  38.    guiopen gcsound.pop
  39. else
  40.    ; dir mode - quit any playing sounds
  41.    call gcsound stop ; stop all sounds
  42. endif
  43.  
  44. xOnFail
  45. guiwindow #this resume
  46.  
  47. xAppicon -1 -1 :gcsound.gc 'GCSound' '' OFF
  48. gadid 5
  49. guiopen #this
  50. setgad #this 5 off
  51.  
  52. ; ===============================================================
  53. ;       the dir listview
  54. ; ===============================================================
  55.  
  56. XLISTVIEW 0 12 250 124 "" file "" 0 DIR
  57. gadid 1
  58. gadfont #mono 8 000
  59. ; on choosing a file by double click, play it..
  60. call gcsound sound $file 0 64 -1
  61.  
  62. xlvdirhook 1
  63. setwintitle #this '$$lv.dir                         '
  64.  
  65. ; ===============================================================
  66. ;       the samples listview - (should make it DBase)
  67. ; ===============================================================
  68.  
  69. XLISTVIEW 0 12 250 124 "" sample t:soundtemp 5 MULTI
  70. gadid 10
  71. gadfont #mono 8 000
  72. gosub gcsound.set settings '$sample'    ; set vol, speed etc
  73.  
  74. ; ===============================================================
  75. ;       the status box
  76. ; ===============================================================
  77.  
  78. TEXT 1 1 248 11 "Idle.." 40 BOX
  79. gadid 2
  80.  
  81. ; ===============================================================
  82. ;       dir lv control buttons
  83. ; ===============================================================
  84.  
  85. XBUTTON 0 0 30 12 "P"
  86. gadid 50
  87. lvuse #this 1
  88. lvdir parent
  89. setwintitle #this '$$lv.dir                         '
  90.  
  91. XBUTTON 30 0 30 12 "D"
  92. gadid 50
  93. lvuse #this 1
  94. lvdir disks
  95. setwintitle #this 'Disks'
  96.  
  97. XBUTTON 60 0 30 12 "S"
  98. gadid 50
  99. lvuse #this 1
  100. if $selswitch = 1
  101.    lvdir all
  102.    selswitch = 0
  103. else
  104.    lvdir none
  105.    selswitch = 1
  106. endif
  107.  
  108. ; ===============================================================
  109. ;       dir lv - add selected
  110. ; ===============================================================
  111.  
  112. XBUTTON 130 0 70 12 "Add"
  113. gadid 50
  114. lvuse gcsound.gc 1
  115. lvmulti first
  116. while $$lv.line > ''            ; skip dirs
  117. and $$lv.type == DIR
  118.    lvmulti next
  119. endwhile
  120. while $$lv.line > ''            ; skip dirs
  121.    if $file H= 'FORM????8SVX'
  122.       lvuse gcsound.gc 10
  123.       lvsearch '$file' ci first ; avoid duplicate entries
  124.       if $$lv.line = ''
  125.          extract file file fname
  126.          rec = '                              '
  127.          rec[0][30] = $fname
  128.          appvar rec '0 64 -1 $file'
  129.          lvadd $rec
  130.       endif
  131.       lvuse gcsound.gc 1
  132.    endif
  133.    lvmulti off
  134.    lvmulti next
  135. endwhile
  136.  
  137. ; ===============================================================
  138. ;       dir lv - switch to samples lv
  139. ; ===============================================================
  140.  
  141. XBUTTON 200 0 50 12 "Ok"
  142. gadid 50
  143. gcsound.gc/mode = SAMPLE
  144. setgad gcsound.gc 10 SHOW               ; show the samples lv
  145. setgad gcsound.gc 2 SHOW                ; show the textin gad
  146. setgad gcsound.gc 1  HIDE               ; hide dir lv
  147. setgad gcsound.gc 50  HIDE              ; hide all dir lv gads
  148. redraw gcsound.gc
  149. setwintitle gcsound.gc 'GCSound 8SVX player'
  150.  
  151. ; ===============================================================
  152. ;       ROUTINE - Split the line into it's components
  153. ; ===============================================================
  154.  
  155. xRoutine splitline line
  156. ; split the line into it's components
  157.  
  158. origline = '$line'   ; store original line
  159. parsevar line
  160.  
  161. ; get name & mode
  162. name = $$parse.0
  163. if $name[0][5] = ''
  164.    status = LOAD
  165.    name = $name[5]
  166. elseif $name[0][7] = ''
  167.    status = PLAY
  168.    name = $name[7]
  169. else
  170.    status = IDLE
  171. endif
  172. extract name clean name
  173.  
  174. times  = $$parse.1
  175. extract times clean times
  176. volume = $$parse.2
  177. extract volume clean volume
  178. speed  = $$parse.3
  179. extract speed clean speed
  180. path = $$parse.4
  181. extract path clean path
  182.  
  183. if $setwin = OPEN
  184.    gosub gcsound.set initsetgads
  185. endif
  186.  
  187. ; ===============================================================
  188. ;       ROUTINE - Join the line & put it back in the list
  189. ; ===============================================================
  190.  
  191. xRoutine joinline
  192. rec = '                              '
  193. rec[0][30] = $name
  194. appvar rec '$times $volume $speed $path'
  195.  
  196. ; add esc seq
  197. if $status = PLAY
  198.    rec = '$rec'
  199. elseif $status = LOAD
  200.    rec = '$rec'
  201. endif
  202.  
  203. ; ===============================================================
  204. ;       ROUTINE - find line place & put it
  205. ; ===============================================================
  206.  
  207. xRoutine putline
  208. ; look for old line & replace it
  209.  
  210. lvuse gcsound.gc 10
  211. lvsearch '$path' ci first
  212. if $$lv.line > ''
  213.    lvput '$rec'
  214. else
  215.    ezreq 'Sample $name was removed!' OK ''
  216. endif
  217.  
  218.  
  219. ; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  220. ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  221. ; ###############################################################
  222.  
  223.         NEWFILE gcsound.pop     ; pop-up on RMB - SAMPLE mode
  224.  
  225. ; ###############################################################
  226. ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  227. ; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  228.  
  229. WinBig 0 0 80 105 ""
  230. WinType 00001000
  231. winonmouse 30 22 
  232. varpath gcsound.gc
  233.  
  234. xOnRMB 
  235. guiclose #this
  236.  
  237. xOnInactive
  238. guiclose #this
  239.  
  240. ; ===============================================================
  241. ;       Change to dir lv
  242. ; ===============================================================
  243.  
  244. XBUTTON 0 0 0 15 "<< Select"
  245. guiclose #this
  246. setgad gcsound.gc 1  SHOW
  247. setgad gcsound.gc 50  SHOW
  248. setgad gcsound.gc 10 HIDE
  249. setgad gcsound.gc 2 HIDE
  250. redraw gcsound.gc
  251. gcsound.gc/mode = DIR
  252. lvuse gcsound.gc 1
  253. setwintitle gcsound.gc '$$lv.dir                         '
  254. lvuse gcsound.gc 10
  255. lvmulti all
  256. gosub gcsound.pop abort    ; abort all playing sounds
  257.  
  258. ; ===============================================================
  259. ;       Play selected sample
  260. ; ===============================================================
  261.  
  262. XBUTTON 0 15 0 15 "Play"
  263. gadhelp 'Play first selected samples'
  264. guiclose #this
  265. lvuse gcsound.gc 10
  266. lvmulti first
  267. while $$lv.line > ''
  268.    gosub gcsound.gc splitline '$sample'
  269.    if $status = LOAD
  270.       call gcsound play $name $times $volume $speed
  271.       status = PLAY
  272.       gosub gcsound.gc joinline
  273.       lvput '$rec'
  274.    elseif $status = IDLE
  275.       call gcsound load $path $name
  276.       call gcsound play $name $times $volume $speed
  277.       status = PLAY
  278.       gosub gcsound.gc joinline
  279.       lvput '$rec'
  280.    endif
  281.    if $$retcode > 0     ; error = audio is full
  282.       lvmulti none
  283.       stop
  284.    endif
  285.    lvmulti off
  286.    lvmulti next
  287. endwhile
  288. lvsort ASC
  289.  
  290. ; ===============================================================
  291. ;       stop current/All sample
  292. ; ===============================================================
  293.  
  294. XBUTTON  0 30 60 15 "Stop"
  295. gadhelp 'Abort selected sample'
  296. guiclose #this
  297. lvuse gcsound.gc 10
  298. gosub #this abort
  299.  
  300. xroutine abort  ; also used below
  301. lvmulti first
  302. while $$lv.line > ''
  303.    if $sample[4][1] = ';'
  304.       gosub gcsound.gc splitline '$sample'
  305.       call gcsound stop $name
  306.       status = LOAD
  307.       gosub gcsound.gc joinline
  308.       lvput '$rec'   ; set plain white
  309.       update gcsound.gc 2 'Stoped $name'
  310.    endif
  311.    lvmulti off
  312.    lvmulti next
  313. endwhile
  314.  
  315. XBUTTON 60 30 20 15 "A"         ; stop all samples
  316. gadhelp 'Abort all samples'
  317. guiclose #this
  318. lvuse gcsound.gc 10
  319. lvmulti all
  320. setgad gcsound.gc 10 HIDE       ; for speed
  321. guiwindow gcsound.gc wait
  322. gosub #this abort
  323. setgad gcsound.gc 10